﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="InTheHand.UI.Xaml.Controls.ProgressRing"
    Width="50"
    Height="50"
    x:Name="Control"
    Foreground="{StaticResource PhoneAccentBrush}">
    <UserControl.Resources>
        <Style x:Key="ProgressRingEllipseStyle" TargetType="Ellipse">
            <Setter Property="Opacity" Value="0"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="Margin" Value="8"/>
            <Setter Property="Height" Value="5"/>
            <Setter Property="Width" Value="5"/>
            <Setter Property="StrokeThickness" Value="0"/>
        </Style>
        <Storyboard x:Key="ProgressRingStoryboard" RepeatBehavior="Forever">
            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Ring">
                <DiscreteObjectKeyFrame KeyTime="0">
                    <DiscreteObjectKeyFrame.Value>
                        <Visibility>Visible</Visibility>
                    </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E1">
                <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.167" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E2">
                <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.334" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E3">
                <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.501" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E4">
                <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.668" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E5">
                <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.21" Value="1"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.22" Value="0"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.47" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetProperty="Angle" Storyboard.TargetName="E1R">
                <SplineDoubleKeyFrame KeySpline="0.13,0.21,0.1,0.7" KeyTime="0" Value="-110"/>
                <SplineDoubleKeyFrame KeySpline="0.02,0.33,0.38,0.77" KeyTime="0:0:0.433" Value="10"/>
                <SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="93"/>
                <SplineDoubleKeyFrame KeySpline="0.57,0.17,0.95,0.75" KeyTime="0:0:1.617" Value="205"/>
                <SplineDoubleKeyFrame KeySpline="0,0.19,0.07,0.72" KeyTime="0:0:2.017" Value="357"/>
                <SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="439"/>
                <SplineDoubleKeyFrame KeySpline="0,0,0.95,0.37" KeyTime="0:0:3.217" Value="585"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.167" Storyboard.TargetProperty="Angle" Storyboard.TargetName="E2R">
                <SplineDoubleKeyFrame KeySpline="0.13,0.21,0.1,0.7" KeyTime="0" Value="-116"/>
                <SplineDoubleKeyFrame KeySpline="0.02,0.33,0.38,0.77" KeyTime="0:0:0.433" Value="4"/>
                <SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="87"/>
                <SplineDoubleKeyFrame KeySpline="0.57,0.17,0.95,0.75" KeyTime="0:0:1.617" Value="199"/>
                <SplineDoubleKeyFrame KeySpline="0,0.19,0.07,0.72" KeyTime="0:0:2.017" Value="351"/>
                <SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="433"/>
                <SplineDoubleKeyFrame KeySpline="0,0,0.95,0.37" KeyTime="0:0:3.217" Value="579"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.334" Storyboard.TargetProperty="Angle" Storyboard.TargetName="E3R">
                <SplineDoubleKeyFrame KeySpline="0.13,0.21,0.1,0.7" KeyTime="0" Value="-122"/>
                <SplineDoubleKeyFrame KeySpline="0.02,0.33,0.38,0.77" KeyTime="0:0:0.433" Value="-2"/>
                <SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="81"/>
                <SplineDoubleKeyFrame KeySpline="0.57,0.17,0.95,0.75" KeyTime="0:0:1.617" Value="193"/>
                <SplineDoubleKeyFrame KeySpline="0,0.19,0.07,0.72" KeyTime="0:0:2.017" Value="345"/>
                <SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="427"/>
                <SplineDoubleKeyFrame KeySpline="0,0,0.95,0.37" KeyTime="0:0:3.217" Value="573"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.501" Storyboard.TargetProperty="Angle" Storyboard.TargetName="E4R">
                <SplineDoubleKeyFrame KeySpline="0.13,0.21,0.1,0.7" KeyTime="0" Value="-128"/>
                <SplineDoubleKeyFrame KeySpline="0.02,0.33,0.38,0.77" KeyTime="0:0:0.433" Value="-8"/>
                <SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="75"/>
                <SplineDoubleKeyFrame KeySpline="0.57,0.17,0.95,0.75" KeyTime="0:0:1.617" Value="187"/>
                <SplineDoubleKeyFrame KeySpline="0,0.19,0.07,0.72" KeyTime="0:0:2.017" Value="339"/>
                <SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="421"/>
                <SplineDoubleKeyFrame KeySpline="0,0,0.95,0.37" KeyTime="0:0:3.217" Value="567"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.668" Storyboard.TargetProperty="Angle" Storyboard.TargetName="E5R">
                <SplineDoubleKeyFrame KeySpline="0.13,0.21,0.1,0.7" KeyTime="0" Value="-134"/>
                <SplineDoubleKeyFrame KeySpline="0.02,0.33,0.38,0.77" KeyTime="0:0:0.433" Value="-14"/>
                <SplineDoubleKeyFrame KeyTime="0:0:1.2" Value="69"/>
                <SplineDoubleKeyFrame KeySpline="0.57,0.17,0.95,0.75" KeyTime="0:0:1.617" Value="181"/>
                <SplineDoubleKeyFrame KeySpline="0,0.19,0.07,0.72" KeyTime="0:0:2.017" Value="331"/>
                <SplineDoubleKeyFrame KeyTime="0:0:2.783" Value="415"/>
                <SplineDoubleKeyFrame KeySpline="0,0,0.95,0.37" KeyTime="0:0:3.217" Value="561"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

    <Grid x:Name="Ring" CacheMode="BitmapCache"  RenderTransformOrigin=".5,.5" Visibility="Collapsed">
        <Canvas CacheMode="BitmapCache" RenderTransformOrigin=".5,.5">
            <Canvas.RenderTransform>
                <RotateTransform x:Name="E1R"/>
            </Canvas.RenderTransform>
            <Ellipse x:Name="E1" Fill="{Binding Foreground, ElementName=Control}" Style="{StaticResource ProgressRingEllipseStyle}" />
        </Canvas>
        <Canvas CacheMode="BitmapCache" RenderTransformOrigin=".5,.5">
            <Canvas.RenderTransform>
                <RotateTransform x:Name="E2R"/>
            </Canvas.RenderTransform>
            <Ellipse x:Name="E2" Fill="{Binding Foreground, ElementName=Control}" Style="{StaticResource ProgressRingEllipseStyle}" />
        </Canvas>
        <Canvas CacheMode="BitmapCache" RenderTransformOrigin=".5,.5">
            <Canvas.RenderTransform>
                <RotateTransform x:Name="E3R"/>
            </Canvas.RenderTransform>
            <Ellipse x:Name="E3" Fill="{Binding Foreground, ElementName=Control}" Style="{StaticResource ProgressRingEllipseStyle}" />
        </Canvas>
        <Canvas CacheMode="BitmapCache" RenderTransformOrigin=".5,.5">
            <Canvas.RenderTransform>
                <RotateTransform x:Name="E4R"/>
            </Canvas.RenderTransform>
            <Ellipse x:Name="E4" Fill="{Binding Foreground, ElementName=Control}" Style="{StaticResource ProgressRingEllipseStyle}" />
        </Canvas>
        <Canvas CacheMode="BitmapCache" RenderTransformOrigin=".5,.5">
            <Canvas.RenderTransform>
                <RotateTransform x:Name="E5R"/>
            </Canvas.RenderTransform>
            <Ellipse x:Name="E5" Fill="{Binding Foreground, ElementName=Control}" Style="{StaticResource ProgressRingEllipseStyle}" />
        </Canvas>
    </Grid>
</UserControl>